package com.ttg.web.dao.Impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ttg.common.entities.BasePage;
import com.ttg.common.utils.DateTimeUtil;
import com.ttg.model.dto.MctInfoListGetDto;
import com.ttg.model.dto.VipInfoListGetDto;
import com.ttg.model.mapper.VipWhiteListMapper;
import com.ttg.model.pojo.VipWhiteList;
import com.ttg.model.vo.VipWhiteListMctGetVo;
import com.ttg.model.vo.VipWhiteListVipGetVo;
import com.ttg.web.dao.VipWhiteListDao;
import org.springframework.stereotype.Service;

import java.util.Objects;

@Service
public class VipWhiteListDaoImpl extends ServiceImpl<VipWhiteListMapper, VipWhiteList> implements VipWhiteListDao {


    @Override
    public BasePage<VipWhiteListMctGetVo> mctGetList(BasePage<VipWhiteListMctGetVo> page, MctInfoListGetDto dto) {
        String startDate =null;
        if(Objects.nonNull(dto.getStartTime())){
            startDate = DateTimeUtil.formatYYYY_MM_DD(dto.getStartTime());
        }

        String endtDate =null;
        if(Objects.nonNull(dto.getEndTime())){
            endtDate = DateTimeUtil.formatYYYY_MM_DD(dto.getEndTime());
        }
        return baseMapper.mctGetList(page,dto,startDate,endtDate);
    }

    @Override
    public BasePage<VipWhiteListVipGetVo> vipGetList(BasePage<VipWhiteListVipGetVo> page, VipInfoListGetDto dto) {
        String startDate =null;
        if(Objects.nonNull(dto.getStartTime())){
            startDate = DateTimeUtil.formatYYYY_MM_DD(dto.getStartTime());
        }

        String endtDate =null;
        if(Objects.nonNull(dto.getEndTime())){
            endtDate = DateTimeUtil.formatYYYY_MM_DD(dto.getEndTime());
        }
        return baseMapper.vipGetList(page,dto,startDate,endtDate);
    }
}
